Skip to content

fix(agenda): all day event offsets, locale display #3695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

tnyeanderson
Copy link
Contributor

Currently, allDay events are off by one day for negative timezones. Per the CalendarContract:

If allDay is set to 1 eventTimezone must be "UTC" and the time must
correspond to a midnight boundary.

For example, in GMT-2:00, an all day event on December 2nd (beginning at 00:00:00) will be wrongly displayed as starting on December 1st, since the locale will determine that the event's start time is actually 22:00:00 on Dec 1.

Source:

https://developer.android.com/reference/android/provider/CalendarContract.Events.html

This commit:

  • Corrects the offset back to UTC 00:00:00 for allDay events

  • Fixes the conditional for single-day all day events in showEvent()

  • Fixes the display of formatDateShort() for some English locales by also removing any trailing commas or whitespace when the year is removed

@tnyeanderson
Copy link
Contributor Author

@glemco it seems like you're the de facto owner of the agenda app, so mentioning you here :)

Copy link
Contributor

@glemco glemco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this! I remember testing this across time-zones was quite convoluted and I didn't know about this Contract.
Added some minor comments but it looks good to me.

@tnyeanderson tnyeanderson force-pushed the agenda-fix branch 2 times, most recently from e315cac to 2d4228f Compare December 13, 2024 15:09
@tnyeanderson
Copy link
Contributor Author

Should be ready for a final review. Thanks!

@tnyeanderson
Copy link
Contributor Author

Forgot to increment version and add the changelog entry... NOW we are good :)

@glemco
Copy link
Contributor

glemco commented Dec 16, 2024

@tnyeanderson did you forget to push? There's still only one changed file in this PR

Currently, allDay events are off by one day for negative timezones. Per
the CalendarContract:

    If allDay is set to 1 eventTimezone must be "UTC" and the time must
    correspond to a midnight boundary.

For example, in GMT-2:00, an all day event on December 2nd (beginning at
00:00:00) will be wrongly displayed as starting on December 1st, since
the locale will determine that the event's start time is actually
22:00:00 on Dec 1.

Source:

https://developer.android.com/reference/android/provider/CalendarContract.Events.html

This commit:

* Corrects the offset back to UTC 00:00:00 for allDay events

* Fixes the conditional for single-day all day events in showEvent()

* Fixes the display of formatDateShort() for some English locales by
  also removing any trailing commas or whitespace when the year is
  removed
@tnyeanderson
Copy link
Contributor Author

Sorry, was in a rush and didn't git add properly :)

@bobrippling
Copy link
Collaborator

Nice work, thanks for the PR @tnyeanderson and the review @glemco!

@bobrippling bobrippling merged commit 0ac4c51 into espruino:master Dec 20, 2024
1 check passed
@tnyeanderson tnyeanderson deleted the agenda-fix branch December 21, 2024 03:49
randyheydon added a commit to randyheydon/BangleApps that referenced this pull request Apr 10, 2025
All-day events synchronized from Gadgetbridge always start at midnight UTC,
which causes them to display as different days depending on time zone offset
(specifically negative offsets display the date as one day early).  This was
previously fixed in the agenda app in pull request espruino#3695 (commit bcf88c3).
This commit replicates that fix in the clockinfo that agenda provides.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants